ARTICLES > Web Programming

[JQuery] Bottom to top page

[JQuery] Bottom to top page

2022-09-22 11:41:40

script นี้ใช้สำหรับเพิ่มความสะดวกให้ผู้เยี่ยมชมเว็บไซต์ โดยจะเพิ่มปุ่มกด scroll up เพื่อใช้เลื่อนหน้าเว็บฯ เพจขึ้นไปยังตำแหน่งบนสุดอย่างรวดเร็ว ซึ่งตัว code จะตรวจจับการ scroll down ลงมาที่ 300px (กำหนดใน javascript) แล้วจะมีปุ่มปรากฏที่มุมล่างด้านขวาของจอ เมื่อ ...
READ MORE

[JQuery] Image checkbox limit range

[JQuery] Image checkbox limit range

2019-10-08 16:04:08

  Example for Video spliting function by interval (time range)   Looping to images (.jpg) in folder ex <ul style="list-style: none" id="thumb-list"> <?php foreach(glob('ex/'.$h.'*.jpg') ...
READ MORE

[SMF] Fix error Unable to load the Ads template

[SMF] Fix error Unable to load the Ads template

2019-03-25 17:39:38

  This problem occurred after some uninstallation, such as Ads management MOD. Don't worry, you can restore files and make the website back to work again. But you still need to find a way to uninstall it.   After ...
READ MORE

[SMF] How to adding adsense into first post of topic

[SMF] How to adding adsense into first post of topic

2019-03-22 23:16:03

For SMF v2.0.15 After submitting website and verified by adsense programs (put code in <head> tag) Ads banner will be ready to display If there is an automatic setting.   For this article, it is recommended to display an Adsense ...
READ MORE

[SMF] Remove Help button from menu bar

[SMF] Remove Help button from menu bar

2019-03-12 17:21:06

  Open file path: ../Themes/Theme_name/index.template.php find the line of function templete_menu(){ and look at the looping (foreach statement) foreach ($context['menu_buttons'] as $act => $button) {...   Insert ...
READ MORE

[PHP] ดึงอัตราแลกเปลี่ยนจาก API ธนาคารชาติ (2022)

[PHP] ดึงอัตราแลกเปลี่ยนจาก API ธนาคารชาติ (2022)

2019-02-25 15:48:24

  จากที่ก่อนหน้านี้ (ปลายปี2018) ทางธนาคารแห่งประเทศไทย (ธปท) ได้พัฒนา API Exchange Rate จากเวอร์ชั่นเก่า มาเป็นตัวใหม่ ส่งผลให้ Application ของเว็บไซ์ที่เคยเขียนไว้ ไม่สามารถเชื่อมต่อ API ตัวเดิมได้ ดังนั้นเราจะมาลองเชื่อมต่อ API ...
READ MORE

[Javascript] Adjust height of iframe after loaded

[Javascript] Adjust height of iframe after loaded

2018-10-09 12:11:13

  $('iframe').load(function() {     this.style.height =     this.contentWindow.document.body.offsetHeight + 'px'; }); Ref: https://stackoverflow.com/questions/3846132/jquery-get-height-of-iframe-content-when-loaded ...
READ MORE

[PHP] Form POST many varaible more 1000 fields

[PHP] Form POST many varaible more 1000 fields

2018-07-06 15:32:38

Set config php.ini max_input_vars = 1000 *Default at 1000 fields   If you want to define many IN condition with sql command  (MySQL) If you want to POST these values (very many fields) to the sql statement via IN ...
READ MORE

[PHP] PHPExcelExport open_basedir restriction

[PHP] PHPExcelExport open_basedir restriction

2018-05-18 00:57:15

PHP Export excel alert: Warning: tempnam(): open_basedir restriction in effect. File() is not within the allowed path(s): __ Warning: fopen(): Filename cannot be empty in __ Insert this code on export page: error_reporting(E_ERROR ...
READ MORE

[JQuery] Allow only input letters and numbers

[JQuery] Allow only input letters and numbers

2018-03-06 18:33:21

$('input[name=xxx]').keyup(function() {     var $th = $(this);     $th.val( $th.val().replace(/[^a-zA-Z0-9]/g, function(str) {      alert('กรุณากรอกข้อมูลเป็นภาษาอังกฤษและตัวเลขเท่านั้น'); ...
READ MORE

[SQL] Grouping data from right table

[SQL] Grouping data from right table

2018-02-22 17:41:33

SELECT z.delivery_type, IF(dt.detail IS NULL or dt.detail = '', pt.status_desc, dt.detail) as DT, count(*) CNT, z.price FROM ( SELECT d.pack_type, d.delivery_type, d.price FROM postmail_header h  RIGHT JOIN ...
READ MORE

[PHP/SQL] Split date and time for update to database

[PHP/SQL] Split date and time for update to database

2018-02-21 16:14:05

1. Get datetime data from some column in database. SELECT date_format(datetime_column,'%Y-%m-%d') DAT, date_format(datetime_column,'%H:%i:%s') TIM FROM table WHERE Something 2. Put data into each an input (eg. datepicker, ...
READ MORE

[MYSQL] Sorting issue (alphanumeric)

[MYSQL] Sorting issue (alphanumeric)

2018-02-08 17:42:11

Wanted: A1, A2, A3, A4,... Z100 But query with sorting (ORDER BY asc) A1 A10 A11 .. A2 A21 A22   My way to works. SELECT issue FROM table ORDER BY substr(issue,1,1) ...
READ MORE

[PHP] Return JSON array back to Jquery

[PHP] Return JSON array back to Jquery

2017-12-25 11:28:05

PHP: (process.php) $json = array(); $json[0] = "Code 1"; $json[1] = "Message"; echo json_encode($json);   AJAX (Jquery): $("some_form").on('submit',(function(e) ...
READ MORE

PHP split multiple condition

PHP split multiple condition

2017-07-26 16:33:04

Split word by space or plus character to array. $arr = preg_split("/[s,+]/", trim($_GET['text_search']));   And call function markWord for replace hightlight styles. function markWord($arr,$str) { ...
READ MORE

Bootstrap modal confirm box

Bootstrap modal confirm box

2017-02-01 14:28:26

  Modal popup for confirm before send post data  <form id="form"> <button type="submit" class="btn btn-success" onclick="return preSave();">บันทึกข้อมูล</button> </form>     <div ...
READ MORE

PHP insert single quote into database

PHP insert single quote into database

2017-01-11 17:57:50

  PHP ฟังก์ชั่นสำหรับจัดการกับ single quote (') ก่อนที่จะ insert ลงฐานข้อมูล function string_sanitize($s) {     $result = str_replace(" ' ", " ' ' ", $s);     return ...
READ MORE

[Form] Input multiple email by multiple select pop

[Form] Input multiple email by multiple select pop

2016-11-14 14:18:01

  Bootstrap Input tags http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/   Jquery Multiple select 2 side http://crlcu.github.io/multiselect/ http://quasipartikel.at/multiselect/   หากข้อมูลมีจำนวนไม่มากนัก ...
READ MORE

[JQuery] Popup page Landing

[JQuery] Popup page Landing

2016-11-01 12:00:40

หลายคนคงจะเคยเห็นกันอยู่บ่อยๆ นะครับ เวลาที่เข้าไปยังเว็บไซต์ใดเว็บนึ่ง แล้วมี Popup เด้งขึ้นมาแสดงที่หน้า Home page ก่อนจะเข้าไปชมเว็บไซต์ ประโยชน์ของ popup ลักษณะนี้ คือสามารถโปรโมต โฆษณา ประชาสัมพันธ์ข้อมูลข่าวสารต่างๆ เพื่อนำเสนอข้อมูลแก่ ...
READ MORE

CSS ทำ paging style ด้วย Bootstrap

CSS ทำ paging style ด้วย Bootstrap

2016-10-04 15:42:47

Include bootstrap.css  (Download) <link rel="stylesheet" type="text/css" href="bootstrap.css"> HTML ให้สร้าง attribute class ชื่อ pagination <ul class="pagination">   ...
READ MORE

PHP Pagination - แบ่งหน้าด้วย php

PHP Pagination - แบ่งหน้าด้วย php

2016-09-29 22:58:43

เป็น PHP ฟังก์ชั่น ที่ใช้สำหรับแบ่งหน้า ในกรณีดึงข้อมูลมาแสดงเป็น Item list พร้อมกับ css จัดรูปแบบเพื่อความสะดวกใช้งาน   pagination.php <?php   function displayPaging( $total, $limit, $pagenumber, $baseurl, ...
READ MORE

PHP upload multiple files

PHP upload multiple files

2016-09-26 13:10:36

PHP โค้ดสำหรับฟอร์มอับโหลดไฟล์ หลายไฟล์ โดยมีการตรวจสอบนามสกุลของไฟล์ และจำกัดขนาด size พร้อมกับเช็ค error ขณะอับโหลด HTML <form action="file_upload.php" method="post" enctype="multipart/form-data"> <input ...
READ MORE

Oracle หาจำนวนวันจาก 2 date

Oracle หาจำนวนวันจาก 2 date

2016-09-23 12:59:29

  Oracle two dates differance (Buddhist year) SELECT to_date('29/09/2559', 'DD/MM/YYYY') -to_date('25/09/2559', 'DD/MM/YYYY') FROM dual; Test result on Toad for Oracle TO_DATE('29/09/2559','DD/MM/YYYY')-TO_DATE('25/09/2559','DD/MM/YYYY') ---------------------------------------------------------------------   ...
READ MORE

Xampp เปลี่ยน password mysql

Xampp เปลี่ยน password mysql

2016-09-20 19:07:22

Video   1. เปิด XAMPP Control ขึ้นมา กดปุ่ม start  ให้กับ apache และ mysql จากนั้นกดปุ่ม admin ที่ MySQL เพื่อเข้าหน้า control panel ของ phpmyadmin   2. เข้าเมนู SQL แล้วพิมพ์ sql ในช่องด้านล่าง UPDATE ...
READ MORE

Ajax Selection เลือกจังหวัด,อำเภอ,ตำบล

Ajax Selection เลือกจังหวัด,อำเภอ,ตำบล

2016-09-17 11:54:12

Script นี้เป็น framework ที่ผมสร้างขึ้นมา ทำงานบน Form ที่ให้ User กรอกรายละเอียดจังหวัด อำเภอ ตำบล และรหัสไปรษณีย์ ซึ่งมีการทำงานแบบ Dropdown List เลือกข้อมูลแบบลำดับขั้น โดยเลือกจากจังหวัดก่อน จากนั้น javascript ที่ทำงานแบบ Ajax จะไป Run คำสั่งในไฟล์ ...
READ MORE

PHP random arrays

PHP random arrays

2016-09-09 17:00:27

PHP Script for random one of array key <?PHP $text = array(); $text[] = 'Content 1'; $text[] = 'Content 2'; $text[] = 'Content 3'; echo $text[ array_rand($text,1) ]; ?> If you want ...
READ MORE

Jquery Input calendar datepicker

Jquery Input calendar datepicker

2016-09-09 12:29:10

datepicker เป็นสคริปท์ที่ถูกใช้งานค่อนข้างบ่อยครั้ง  สำหรับผู้ที่ต้องเขียน form input วัน/เดือน/ปี และส่วนตัวผมก็ใช้แทบทุกเว็บไซต์ที่มี back office  เมื่อเวลาจะใช้ที ก็หลงๆลืมๆ ว่าจะใช้ไฟล์ไหนหรือฟังก์ชั่นอะไรบ้าง ผมเลยถือโอกาสนี้ นำมันมารวบรวมไว้บนเว็บฯ ...
READ MORE

PHP Redirect back to previous page after login

PHP Redirect back to previous page after login

2016-09-09 11:15:25

  The PHP script including condition terms before loaded content. If the condition is false The script will redirecting back to the login page with location parameters.   Main page (index.php) <?php   if ...
READ MORE

Printing on Lotus notes web agent

Printing on Lotus notes web agent

2016-09-08 16:55:06

This is a technique used for printing documents on the browser for Lotusnotes Web application platform. It uses javascript in through ajax function to run commands on lotusnotes script and return by print plain text with a Html header.   This ...
READ MORE

[Javascript] remove HTML tag from plain text

[Javascript] remove HTML tag from plain text

2016-09-06 17:10:10

เป็นฟังชั่นในการตัด html tag ออกจาก text เพื่อการใช้งานข้อมูลแบบ plain text  function strip(html) {    var tmp = document.createElement("DIV");    tmp.innerHTML = html;    return ...
READ MORE

แก้ปัญหา window.showModalDialog is not a function

แก้ปัญหา window.showModalDialog is not a function

2016-09-06 12:09:07

Uncaught TypeError: window.showModalDialog is not a function เป็นเพราะ Chrome ในเวอชั่นใหม่ๆ ได้เลิก support function นี้ ดังนั้น เราจึงต้องปรับเปลี่ยนวิธีการเปิด popup ใหม่ showModalDialog มีข้อดีคือ มันสามารถส่งตัวแปรไปรับค่าจาก popup แล้ว ...
READ MORE

SEO: Submit sitemap ให้กับ Google,Bing

SEO: Submit sitemap ให้กับ Google,Bing

2016-09-05 11:42:40

ประโยชน์ของการ submit ไฟล์ sitemap กับเว็บไซต์ search engine นั้น  เปรียบเสมือนการทำสารบัญเว็บไซต์  เพื่อให้กับเว็บค้นหาอย่าง google, bing เพื่อให้มันจัดเก็บแผนผังเว็บไซต์ของเราไว้ในฐานข้อมูลเว็บเสริชเหล่านั้น  ทำให้ช่วยในเรื่อง SEO ...
READ MORE

ใส่ comma ใน number ตัวเลขจำนวนเงิน (PHP,Javascript,Lotus notes)

ใส่ comma ใน number ตัวเลขจำนวนเงิน (PHP,Javascript,Lotus notes)

2016-09-05 11:20:43

สำหรับ PHP สามารถใช้ฟังก์ชั่น format_number ได้เลย ถูกใช้บ่อยในการเขียนโปรแกรมเกี่ยวกับตัวเลข จำนวนเงิน Price   PHP Function $number = 1234.5678 echo number_format($number, 2); // Output:   1,234.57 Lotus ...
READ MORE

[PHP] ดึงภาพจาก Pinterest มาแสดงบนเว็บไซต์

[PHP] ดึงภาพจาก Pinterest มาแสดงบนเว็บไซต์

2016-08-10 17:01:45

การดึงภาพและข้อมูลอื่นๆที่เกี่ยวข้องจาก board ในเว็บไซต์ Pinterest นั่น เราสามารถทำผ่าน API ที่เขาจัดเตรียมไว้ให้ ซึ่งวิธีการนั้นง่ายมากๆ ครับ แต่ก่อนอื่นคุณเป็นเป็นสมาชิกของ pinterest ก่อนนะ  แล้วเข้าไปที่   1. เข้าไปที่หน้า  https://developers.pinterest.com/   ...
READ MORE

ดึงภาพจาก Instagram มาแสดงบนเว็บไซต์ด้วย PHP

ดึงภาพจาก Instagram มาแสดงบนเว็บไซต์ด้วย PHP

2016-08-09 19:10:34

1. ลำดับแรกคุณต้องมี Account ของ Instagram ก่อนนะครับ  จากนั้นเข้าไปที่หน้านี้เลย https://www.instagram.com/developer 2. จากนั้นเลือก Manage Clients  และกดปุ่ม Register a new client   3. กรอกรายละเอียดที่จำเป็น ...
READ MORE

[Jquery] enable select option box

[Jquery] enable select option box

2016-01-01 00:00:01

Jquery enable select option box (disabled attribute) Not work $('select[test]').attr('disabled',''); Work $('select[test]').prop('disabled',false);   ...
READ MORE

PHP Check ตัวอักษรภาษาไทย

PHP Check ตัวอักษรภาษาไทย

2015-09-20 12:37:42

PHP script สำหรับตรวจสอบข้อความ เช็คตัวอักษร ว่าเป็นอักษรไทย และวรรณยุกต์ หรือไม่ <?PHP   if(!ereg('^[ก-์ ะ-ู เ-แ]+$', $text)) {              // Something ...
READ MORE

delivery-failure-sent-maildoc-to-gmail-lotusnotes-mail-library

delivery-failure-sent-maildoc-to-gmail-lotusnotes-mail-library

2015-09-20 11:23:29

แก้ปัญหาการส่งอีเมลจาก Lotus Notes web platform ส่งเข้า Gmail แล้วไม่มี Form header ปัญหานี้เกิดจาก การสร้างตัวแปร string ที่มีเครื่องหมาย น้อยกว่า (<) หรือมากกว่า ( >) รวมอยู่ใน string แล้วคลุมด้วย Double quote ("__") ทำให้โปรแกรมตีความหมายผิดพลาด ...
READ MORE

SQL: Time slot booking

SQL: Time slot booking

2015-01-27 15:12:54

  SQL Query finding range an overlaps another booking (Time): SELECT COUNT(*) FORM Table_name WHERE NOT ('8:00:00' > Table.endtime OR '9:40:00' < Table.starttime) Reference: http://stackoverflow.com/questions/ ...
READ MORE

PHP convert month,year to Thai date

PHP convert month,year to Thai date

2015-01-24 14:20:22

  PHP ใช้แปลง date เป็นเดือนไทย พ.ศ. $month_arr=array(     "1"=>"มกราคม",     "2"=>"กุมภาพันธ์",     "3"=>"มีนาคม",   ...
READ MORE

PHP ตัด HTML tag ออกจาก Text ตัวอักษร

PHP ตัด HTML tag ออกจาก Text ตัวอักษร

2014-09-23 15:01:08

PHP strip_tags เป็นฟังก์ชั่นตัด html tag ให้เหลือไว้เพียง Content text ที่อยู่ภายใน tag นั้น <?php $text = '<p>Test paragraph + <span style="color:red">Read more</span></p> <a href="#"><b>link</b></a>'; echo ...
READ MORE

How to get Date from DateTime format in SQL

How to get Date from DateTime format in SQL

2013-03-27 15:33:51

วิธีการ query ข้อมูลโดยเปรียบเทียบจากวันที่ DateTime ในฐานข้อมูล Mssql (Date only) ตัวอย่าง SELECT * FROM table WHERE convert(char(10), Field_date , 103) = '20/12/2013' ซึ่งเลข 103 คือ format แบบ d/m/Y   อ้างอิงจาก: http://www.w3schools.com/sql/func_convert.asp ...
READ MORE

[Javascript] Select box navigation (Onchange go to URL)

[Javascript] Select box navigation (Onchange go to URL)

2013-03-11 15:13:51

javascript แบบ inline สำหรับการใช้งาน เปลี่ยน address ไปยังหน้าเพจที่ต้องการ ด้วยการใช้ select box และ onchange event ตัวอย่าง <select onchange='document.location.href=this.options[this.selectedIndex].value;'> <option ...
READ MORE

การเรียก ready function ให้ทำงานอีกครั้ง

การเรียก ready function ให้ทำงานอีกครั้ง

2013-02-28 12:11:46

ปัญหานี้เกิดขึ้นจากการวางคำสั่งไว้ใน $().ready(function() { ... } ซึ่งจะสามารถทำงานได้ครั้งเดียวที่โหลดเพจขึ้นมา แต่ถ้ามีการเขียน เปลี่ยนแก้ไข html แบบ dynamic โดยใช้ innerText innerHtml , ajax หรือพวก open popup แล้วจะกลับมาทำงานในหน้า window.opener ซึ่งบางงาน ...
READ MORE

MySQL หาค่าเฉลี่ยสูงสุดในแต่ละ Group

MySQL หาค่าเฉลี่ยสูงสุดในแต่ละ Group

2013-02-12 17:50:31

คำสั่ง SQL ใช้สำหรับเรียกดูข้อมูล ที่มีค่าที่สูงที่สุด ในแต่ละ group ตัวอย่าง. การหาค่าเฉลี่ยของเงินเดือนที่สูงสุดในแต่ละแผนก   SELECT Department,max(avg_sal) FROM ( SELECT Department,avg(salary) as avg_sal FROM employee GROUP ...
READ MORE